<?php
/**
 * Class to handle Bootstrap Accordion Collapse elements
 *
 * @author		Joachim Ruf, Loresoft Software (http://www.loresoft.de)
 * @license		New BSD License
 * @version		Class for Bootstrap v2.3.2
 *
 * */


Class Bootstrap_Accordion_Handler
{
	private $arrItem			= array();

	/**
	 *
	 * */
	function __construct () {

	}


	/**
	 * Erstellt ein Carousel-Item
	 * @param string $_content		: Auszugebender Content
	 * @return string
	 * */
	public function addItem ($_id, $_title, $_content, $_expand = false) {
		$this->arrItem[$_id] = array('title'	=> $_title,
									 'content'	=> $_content,
									 'expand'	=> $_expand);
	}


	public function display ($_id) {
		$content		= '';

		if (!count($this->arrItem)) {
			return NULL;
		}

		foreach ($this->arrItem as $key => $arrVal) {
			$id		= $key;
			$title	= $arrVal['title'];
			$text	= $arrVal['content'];
			$expand	= ($arrVal['expand'] === true) ? ' in' : '';

			$content .= '<div class="accordion-group">
							<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse" data-parent="#'.$_id.'" href="#'.$id.'">'.$title.'</a>
							</div>
							<div id="'.$id.'" class="accordion-body collapse'.$expand.'">
								<div class="accordion-inner">
									'.$text.'
								</div>
							</div>
						</div>

					';
		}

		return '<div class="accordion" id="'.$_id.'">
					'.$content.'
				</div>
				';
	}


}


?>